//实验数据接口的管理
import $http from '@/service/request.js'

//功能：根据实验名称查询实验数据（预期）
//接口：/expers/{name}
//GET
export const _getExperByName = (name) =>{
	return $http.request({
		url:'/expers' + '/' + name,
		method:'GET',
		header:{
			"Content-Type":"application/json"
		}
	})
}

//功能：获取所有专业实验
//接口：/expers
//GET
export const _getAllExper = () =>{
	return $http.request({
		url:'/expers',
		method:'GET',
		header:{
			"Content-Type":"application/json"
		}
	})
}



//功能：上传实验数据
//接口：/jrlequips/controldata
//GET
export const _sendcontroldata = (data) =>{
	return $http.request({
		url:'/jrlequips/controldata',
		method:'POST',
		header:{
			"Content-Type":"application/json"
		},
		data
	})
}

//功能：存储实验完成
//接口：/myexpers/saveover
//POST
export const _saveover = ({account_user,name_equip,name_exper}) =>{
	return $http.request({
		url:'/myexpers/saveover',
		method:'POST',
		header:{
			"Content-Type":"application/json"
		},
		data:{
			account_user,
			name_equip,
			name_exper
		}
	})
}

//功能：查询实验完成
//接口：/myexpers/selectover
//POST
export const _experovermessage = ({account_user}) =>{
	return $http.request({
		url:'/myexpers/selectover',
		method:'POST',
		header:{
			"Content-Type":"application/json"
		},
		data:{
			account_user
		}
	})
}
//功能：拉取特定的一次实验数据，模拟实验过程，仅供图表测试用
//接口：/common/returnTemp
//GET
export const _test = (data) =>{
	return $http.request({
		url:'/common/returnTemp?row='+data,
		method:'GET',
		header:{
			"Content-Type":"application/json"
		}
	})
}
//功能：拉取特定的一次实验数据，模拟实验过程，仅供图表测试用
//接口：/woonSocket/searchTemp
// 
export const _searchTemp = (data) =>{
	return $http.request({
		url:'/woonSocket/searchTemp?'+data,
		method:'GET',
		header:{
			"Content-Type":"application/json"
		}
	})
}

//删除
//接口：/woonSocket/removeMessage
//DELETE
export const _removeMessage = (serialnum) =>{
	return $http.request({
		url:'/woonSocket/removeMessage?serialnum='+serialnum,
		method:'DELETE',
		header:{
			"Content-Type":"application/json"
		},
	})
}

//可能废弃
//更改最近实验时间以及实验人
//接口：equips/updateLab
//POST
export const _postUserInfo = (somedata) =>{
	console.log({somedata});
	return $http.request({
		url:'/equips/updateLab',
		method:'POST',
		header:{
			"Content-Type":"application/json"
		},
		data:somedata

	})
}

//将使用者变为空
//接口：/equips/deleteUser
//POST
export const _reSetUser = ({somedata}) =>{
	return $http.request({
		url:'/equips/deleteUser',
		method:'POST',
		header:{
			"Content-Type":"application/json"
		},
		data:{
			somedata
		}
	})
}

//已经废弃了吧
//获取了设备的一些信息，主要是run_time这个设备最后一次实验的时间
//接口：/equips/deleteUser
//POST
export const _getSomeData = (serialnum_equip) =>{
	return $http.request({
		url:'/equips/selectEquip?serialnum_equip='+serialnum_equip,
		method:'GET',
		header:{
			"Content-Type":"application/json"
		}
	})
}
//预约设备
//接口：/equips/resEquip
//POST
export const _resEquip = ({serialnum_equip,res_user,start_time,end_time}) =>{
	return $http.request({
		url:'/equips/resEquip',
		method:'POST',
		header:{
			"Content-Type":"application/json"
		},
		data:{
			serialnum_equip,
			res_user,
			start_time,
			end_time
		}
	})
}
//查询设备此刻是否被预约
//接口：/equips/findResEquip
//POST
export const _findResEquip = (serialnum) =>{
	return $http.request({
		url:`/equips/findResEquip?serialnum=${serialnum}`,
		method:'GET',
		header:{
			"Content-Type":"application/json"
		},
		data:{}
	})
}

//查询设备预约情况
//接口：/equips/findEquipRes
//POST
export const _findEquipRes = (serialnum) =>{
	return $http.request({
		url:`/equips/findEquipRes?serialnum=${serialnum}`,
		method:'GET',
		header:{
			"Content-Type":"application/json"
		},
		data:{}
	})
}

//取消预约
//接口：/equips/findEquipRes
//POST
export const _cancelRes = (id) =>{
	return $http.request({
		url:`/equips/cancelReservation?id=${id}`,
		method:'DELETE',
		header:{
			"Content-Type":"application/json"
		},
		data:{}
	})
}
//修改设备预约时间
//接口：/equips/modifyResEquip
//POST
export const _modifyRes = ({id,serialnum_equip,res_user,start_time,end_time}) =>{
	console.log(id,serialnum_equip,res_user,start_time,end_time)
	return $http.request({
		url:'/equips/modifyResEquip',
		method:'POST',
		header:{
			"Content-Type":"application/json"
		},
		data:{
			id,
			serialnum_equip,
			res_user,
			start_time,
			end_time
		}
	})
}
//开始计时
//接口：/common/start/{id}
//POST
export const _startRecordTime = (serialnum_equip) =>{
	return $http.request({
		url:`/common/start/${serialnum_equip}`,
		method:'POST',
		header:{
			"Content-Type":"application/json"
		},
		data:{}
	})
}
//暂停计时
//接口：/common/pause/{id}
//POST
export const _pauseRecordTime = (serialnum_equip) =>{
	return $http.request({
		url:`/common/pause/${serialnum_equip}`,
		method:'POST',
		header:{
			"Content-Type":"application/json"
		},
		data:{}
	})
}
//继续计时
//接口：/common/resume/{id}
//POST
export const _resumeRecordTime = (serialnum_equip) =>{
	return $http.request({
		url:`/common/resume/${serialnum_equip}`,
		method:'POST',
		header:{
			"Content-Type":"application/json"
		},
		data:{}
	})
}
//可以废弃
//查看计时
//接口：/common/check/{id}
//GET
export const _checkTime = (serialnum_equip) =>{
	return $http.request({
		url:`/common/check/${serialnum_equip}`,
		method:'GET',
		header:{
			"Content-Type":"application/json"
		},
		data:{}
	})
}

//废弃
//为后端提供初始化表格的数据
//接口：/historys/init
//POST
export const _sendChartInitData = (data) =>{
	console.log(data)
	return $http.request({
		url:`/historys/init`,
		method:'POST',
		header:{
			"Content-Type":"application/json"
		},
		data
	})
}
//为后端提供初始化表格的数据
//接口：/historys/getCurrentData
//GET
export const _getChartData = (serialnum) =>{
	return $http.request({
		url:`/historys/getCurrentData?serialnum=${serialnum}`,
		method:'GET',
		header:{
			"Content-Type":"application/json"
		},
		data:{}
	})
}

//初始化实验数据
//接口：/myexpers/start
//POST
export const _initExperData = ({serialnum,temporary,chartStructure,experName,run_user}) =>{
	return $http.request({
		url:`/myexpers/start`,
		method:'POST',
		header:{
			"Content-Type":"application/json"
		},
		data:{
            serialnum,
            temporary,
            chartStructure,
            experName,
            run_user
        }
	})
}
//设置控制码
//接口：/equips/setControlCode
//POST
export const _setControlCode = ({controlCode,serialnum_equip}) =>{
	return $http.request({
		url:`/equips/setControlCode`,
		method:'POST',
		header:{
			"Content-Type":"application/json"
		},
		data:{
			controlCode,
			serialnum_equip
		}
	})
}
//获取权限
//接口：/equips/confirmPermission
//POST
export const _getPermission = ({controlCode,serialnum_equip,run_user}) =>{
	return $http.request({
		url:`/equips/confirmPermission`,
		method:'POST',
		header:{
			"Content-Type":"application/json"
		},
		data:{
			controlCode,
			serialnum_equip,
			run_user
		}
	})
}
//判断权限
//接口：/equips/isController
//POST
export const _isController = ({serialnum_equip,run_user}) =>{
	return $http.request({
		url:`/equips/isController`,
		method:'POST',
		header:{
			"Content-Type":"application/json"
		},
		data:{
			run_user,
			serialnum_equip
		}
	})
}
